RED='\033[0;31m'
GREEN='\033[0;32m'
NC='\033[0m' 

function until_success() {
    ROUND=0
    while true
    do
	echo "$GREEN\rCURRENT ROUND$NC: $ROUND"
        if eval "$@"; then
            return
        fi
        ROUND=$[$ROUND+1]
	echo "$GREEN\rNEXT ROUND$NC: $ROUND"
	sleep 5s
    done
    ROUND=
}

function until_fail() {
    until ! eval "$@"; do done
}

function until_count() {
    ROUND=0
    while [ $ROUND -lt $1 ]
    do
        ROUND=$[$ROUND+1]
        eval ${@:2}
    done
    ROUND=
}
